package com.jason.campusinn.view;

import java.util.ArrayList;
import java.util.List;

import com.yuandian.wanna.R;
import com.yuandian.wanna.utils.BigStone;
import com.yuandian.wanna.utils.LogUtil;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.Handler;
import android.os.Message;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.GestureDetector.SimpleOnGestureListener;

public class RoundSpinView2 extends View {
	private Paint mPaint = new Paint();  //画出的圈
	private Paint mPaint_sel = new Paint(); //点击后的圈
	private PaintFlagsDrawFilter pfd;  //去除图片缩放的边缘锯齿


	private int startMenu;   //菜单的第一张图片的资源id

	// stone列表
	private List<BigStone> mStones;
	private List<BigStone> mTotalStones;

	// 圆心坐标
	private int mPointX = 0, mPointY = 0;
	// 半径
	private int mRadius = 0;
	// 每两个点间隔的角度
	private int mDegreeDelta;

	private int menuRadius; // 菜单的半径
	private int menuRadio = 0;//菜单半径占一半屏幕的比例

	private int mCur = -1; // 正在被移动的menu;

	private boolean[] quadrantTouched;   //对每个象限触摸情况的记录

	// Touch detection
	private GestureDetector mGestureDetector;

	private onRoundSpinViewListener mListener;  //自定义事件监听器

	private final static int TO_ROTATE_BUTTON = 0;  //旋转按钮；

	private float mbtnBack_x; //返回按钮的X坐标
	private float mbtnBack_y; //返回按钮的Y坐标

	private int m_cur_total_index;//当前显示的总个数，从0开始加，每转出一个点，这个数+1，知道等于总个数，然后清零
	private double startAngle;
	private int m_cur_sel=-2;
	private int mFirstAngle = 0;


	private Handler handler = new Handler(){
		public void handleMessage(Message msg) {
			switch (msg.what) {
				case TO_ROTATE_BUTTON:
					float velocity = Float.parseFloat(msg.obj.toString());
					rotateButtons(velocity/75);
					velocity /= 1.05F;
					new Thread(new FlingRunnable(velocity)).start();
					break;

				default:
					break;
			}
		};
	};

	public interface onRoundSpinViewListener{
		public void onSingleTapUp(int position, int cur);  //监听每个菜单的单击事件
		public void onSingleTrag(int position);
	}

	public RoundSpinView2(Context context,AttributeSet attrs) {
		super(context,attrs);
		if(attrs!=null){
			TypedArray a = getContext().obtainStyledAttributes(attrs,
					R.styleable.RoundSpinView);
			startMenu = a.getResourceId(R.styleable.RoundSpinView_menuStart, 0);
		}
		pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG|Paint.FILTER_BITMAP_FLAG);
		mPaint.setColor(Color.WHITE);
		mPaint.setStrokeWidth(5);
		mPaint.setAntiAlias(true); //消除锯齿  
		mPaint.setStyle(Paint.Style.STROKE); //绘制空心圆 

		mPaint_sel.setColor(Color.RED);
		mPaint_sel.setStrokeWidth(5);
		mPaint_sel.setAntiAlias(true); //消除锯齿  
		mPaint_sel.setStyle(Paint.Style.STROKE); //绘制空心圆 

		quadrantTouched = new boolean[] { false, false, false, false, false };
		mGestureDetector = new GestureDetector(getContext(),
				new MyGestureListener());

		m_btnshow = false;
	}

	public void initStonesList(List<BigStone> list, int visible_cnt) //第二个参数是屏幕上有多少个BigStone
	{
		if(mTotalStones!=null)
		{
			mTotalStones.clear();
		}

		mTotalStones = list;

		setupStones(visible_cnt);

		initStones();


	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		//mPointX = this.getMeasuredWidth()/2;
		//mPointY = this.getMeasuredHeight()/2;

		//初始化半径和菜单半径
		if( menuRadio <= 0){
			mRadius = mPointX-mPointX/4;
			menuRadius = (int)(mPointX/4);
		}else{
			mRadius = mPointX-mPointX/menuRadio;
			menuRadius = (int)(mPointX/menuRadio);
		}


	}

	/**
	 * 初始化每个点
	 */
	private void setupStones(int count) {
		mStones = new ArrayList<BigStone>();
		BigStone stone;
		int angle;//第一个菜单距离水平0度的初始角度
		if( mFirstAngle == 0 ){
			angle = 300;
			mFirstAngle = 300;
		}else{
			angle = mFirstAngle;
		}

//		if(count<8)
//		{
//			count = 8;
//		} else {
//			if(count>12)
//			{
//				count = 8;
//			}
//		}

		count = 8;

		mDegreeDelta = 360 / count;
		//mDegreeDelta = 360 / 8;



		for (int index = 0; index < count; index++) {
			stone = new BigStone();
			if (angle >= 360) {
				angle -= 360;
			}else if(angle < 0){
				angle += 360;
			}
			stone.angle = angle;

			stone.bitmap = BitmapFactory.decodeResource(getResources(),
					startMenu + index);

			angle += mDegreeDelta;

			stone.isVisible = false;

			mStones.add(stone);

		}

	}
	private void initStones()
	{

		//for (int index = 0; index < mStones.size(); index++) {

		//int cnt = Math.min(mStones.size(), mTotalStones.size());

		for (int index = 0; index < mStones.size(); index++) {
			//for (int index = 0; index < cnt; index++) {

			if(mStones.get(index).angle>=180&&mStones.get(index).angle<=mFirstAngle&&index<mTotalStones.size())
			{
				//mStones.get(index).bitmap = mTotalStones.get(index).bitmap;
				//mStones.get(index).isFirstShow = false;
				mStones.get(index).index = 0;
			} else {
				//mStones.get(index).isFirstShow = true;
				mStones.get(index).index = -1;
			}

		}

		//m_left_in = mTotalStones.size();

		mbtnBack_x = mPointX
				+ (float) (mRadius * Math.cos(Math.toRadians(mFirstAngle - 30)));
		mbtnBack_y = mPointY
				+ (float) (mRadius * Math.sin(Math.toRadians(mFirstAngle - 30)));

		invalidate();
	}

	/**
	 * 重新计算每个点的角度
	 */
	public void resetStonesAngle(float x, float y) {
		int angle = computeCurrentAngle(x, y);
		Log.d("RoundSpinView", "angle:" + angle);
		for (int index = 0; index < mStones.size(); index++) {
			mStones.get(index).angle = angle;
			angle += mDegreeDelta;
		}
	}

	/**
	 * 计算每个点的坐标
	 */
	private void computeCoordinates() {
		BigStone stone;
		for (int index = 0; index < mStones.size(); index++) {
			stone = mStones.get(index);
			stone.x = mPointX
					+ (float) (mRadius * Math.cos(Math.toRadians(stone.angle)));
			stone.y = mPointY
					+ (float) (mRadius * Math.sin(Math.toRadians(stone.angle)));
		}
	}

	/**
	 * 计算某点的角度
	 *
	 * @param x
	 * @param y
	 * @return
	 */
	private int computeCurrentAngle(float x, float y) {
		float distance = (float) Math
				.sqrt(((x - mPointX) * (x - mPointX) + (y - mPointY)
						* (y - mPointY)));
		int degree = (int) (Math.acos((x - mPointX) / distance) * 180 / Math.PI);
		if (y < mPointY) {
			degree = -degree;
		}

//		Log.d("RoundSpinView", "x:" + x + ",y:" + y + ",degree:" + degree);
		return degree;
	}

	private boolean isTragIn(int x, int y)
	{
		boolean rtn = false;

		if((Math.abs(x-mPointX)<mRadius/2)&&
				(Math.abs(y-mPointY)<mRadius/2))
		{
			rtn = true;
		}

		return rtn;
	}

	public boolean m_moving = false;
	int x_down;
	@Override
	public boolean dispatchTouchEvent(MotionEvent event) {
		// resetStonesAngle(event.getX(), event.getY());
		// computeCoordinates();
		// invalidate();

		int x, y;

		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			x = (int) event.getX();
			y = (int) event.getY();
			x_down = x;
			mCur = getInCircle(x, y);
			if (mCur == -1) {
				startAngle = computeCurrentAngle(x, y);
			} else {
				//startAngle = computeCurrentAngle(x, y);
			}
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			x = (int) event.getX();
			y = (int) event.getY();
			if (mCur != -1) {
//				mStones[mCur].x = x;
//				mStones[mCur].y = y;
//				invalidate();
			} else {
				double currentAngle = computeCurrentAngle(x, y);
				//TODO: 滑动选择
				//rotateButtons(startAngle - currentAngle);
				//if(currentAngle>startAngle)
//				if(!m_moving)
//				{
//					m_moving = true;
//					Log.e("ACTION_MOVE", String.valueOf(currentAngle - startAngle));
//
//					//if(Math.abs(currentAngle - startAngle)<6)
//					{
//						//rotateButtons(currentAngle - startAngle);
//					}
//
//					if(currentAngle - startAngle>0)
//					{
//						rotateButtons(30);
//					} else {
//						if(currentAngle - startAngle<0)
//						{
//							rotateButtons(-30);
//						}
//					}
//
//					////////////rotateButtons(startAngle - currentAngle);
//					startAngle = currentAngle;
//					m_moving = false;
//				}
			}

		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			x = (int) event.getX();
			y = (int) event.getY();

//			double currentAngle = computeCurrentAngle(x, y);
//			//TODO: 滑动选择
//			//rotateButtons(startAngle - currentAngle);
//			//if(currentAngle>startAngle)
//			{
//				rotateButtons(currentAngle - startAngle);
//				//rotateButtons(startAngle - currentAngle);
//				startAngle = currentAngle;
//			}

//			double currentAngle = computeCurrentAngle(x, y);
//			//TODO: 滑动选择
//			{
//
//				startAngle = currentAngle;
//			}

			if (mCur != -1) {
				computeCoordinates();

				//TODO: if you want to swap the button among each others, uncomment below lines.
//				int cur = getInCircle(x, y);
//				if (cur != mCur && cur != -1) {
//					int angle = mStones[mCur].angle;
//					mStones[mCur].angle = mStones[cur].angle;
//					mStones[cur].angle = angle;
//				}




				if(isTragIn(x,y))
				{
					mListener.onSingleTrag(mStones.get(mCur).index);
				}

				computeCoordinates();
				invalidate();
				mCur = -1;
			} else {
				double currentAngle = computeCurrentAngle(x, y);
				if(!m_moving)
				{
					m_moving = true;
					//Log.e("ACTION_MOVE", String.valueOf(currentAngle - startAngle));

					//if(Math.abs(currentAngle - startAngle)<6)
					{
						//rotateButtons(currentAngle - startAngle);
					}

					if(currentAngle - startAngle>0)
					{
						//rotateButtons(30);
						autorotateButtons(700);
					} else {
						if(currentAngle - startAngle<0)
						{
							//rotateButtons(-30);
							autorotateButtons(-700);
						}
					}

//					if (x_down-x>0)
//					{
//						autorotateButtons(800);
//					} else {
//						autorotateButtons(-800);
//					}


					////////////rotateButtons(startAngle - currentAngle);
					startAngle = currentAngle;
					m_moving = false;
				}
			}


		}

		// set the touched quadrant to true
		quadrantTouched[getQuadrant(event.getX() - mPointX,
				mPointY - event.getY())] = true;
		mGestureDetector.onTouchEvent(event);
		return true;
	}

	private class MyGestureListener extends SimpleOnGestureListener {
		@Override
		public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
							   float velocityY) {
//			// get the quadrant of the start and the end of the fling
//			int q1 = getQuadrant(e1.getX() - mPointX, mPointY - e1.getY());
//			int q2 = getQuadrant(e2.getX() - mPointX, mPointY - e2.getY());
//
//			// the inversed rotations
//			if ((q1 == 2 && q2 == 2 && Math.abs(velocityX) < Math
//					.abs(velocityY))
//					|| (q1 == 3 && q2 == 3)
//					|| (q1 == 1 && q2 == 3)
//					|| (q1 == 4 && q2 == 4 && Math.abs(velocityX) > Math
//							.abs(velocityY))
//					|| ((q1 == 2 && q2 == 3) || (q1 == 3 && q2 == 2))
//					|| ((q1 == 3 && q2 == 4) || (q1 == 4 && q2 == 3))
//					|| (q1 == 2 && q2 == 4 && quadrantTouched[3])
//					|| (q1 == 4 && q2 == 2 && quadrantTouched[3])) {
//
//				// CircleLayout.this.post(new FlingRunnable(-1
//				// * (velocityX + velocityY)));
//				//new Thread(new FlingRunnable(-(velocityX+velocityY))).start();
//			} else {
//				// the normal rotation
//				// CircleLayout.this
//				// .post(new FlingRunnable(velocityX + velocityY));
//				new Thread(new FlingRunnable((velocityX+velocityY))).start();
//			}

			return true;

//			return false;

		}

		@Override
		public boolean onSingleTapUp(MotionEvent e) {

			if (getInOk((int)e.getX(),(int)e.getY())==1)
			{
				if(mListener!=null){
					mListener.onSingleTapUp(-1, (mFirstAngle - 30));
					m_cur_sel = -2;
				}

				m_top_in=0;
				m_left_in=-1;
				mStones = null;
				return true;
			}

			int cur = getInCircle((int)e.getX(),(int)e.getY());
			if(cur!=-1){
				if(mListener!=null){
					mListener.onSingleTapUp(mStones.get(cur).index, mStones.get(cur).angle);
				}

				m_cur_sel = mStones.get(cur).index;
				invalidate();
				return true;
			}
			return false;
		}

	}

	private class FlingRunnable implements Runnable{

		private float velocity;

		public FlingRunnable(float velocity){
			this.velocity = velocity;
		}

		@Override
		public void run() {
			if(Math.abs(velocity)>=200){
				Message message = Message.obtain();
				message.what = TO_ROTATE_BUTTON;
				message.obj = velocity;
				handler.sendMessage(message);
			}
		}

	}

	/**
	 * @return The selected quadrant.
	 */
	private static int getQuadrant(double x, double y) {
		if (x >= 0) {
			return y >= 0 ? 1 : 4;
		} else {
		}
		return y >= 0 ? 2 : 3;
	}


	public int m_top_in=0;
	public int m_left_in=-1;
	public boolean top_in_end = false;
	public boolean left_in_end= false;
	/*
	 * 旋转菜单按钮
	 */
	private void rotateButtons(double degree) {

		if(mTotalStones==null)
		{
			return;
		}

		if(mStones==null)
		{
			return;
		}

		if(top_in_end)
		{
			if(degree<0)
			{
				top_in_end = false;
			} else {
				return;
			}
		}

		if(left_in_end)
		{
			if(degree>0)
			{
				left_in_end = false;
			} else {
				return;
			}
		}

		for (int i = 0; i < mStones.size(); i++) {

			mStones.get(i).angle += degree;
			if (mStones.get(i).angle < 0) {
				mStones.get(i).angle += 360;
			}else if(mStones.get(i).angle >=360){
				mStones.get(i).angle -= 360;
			}


			if((mStones.get(i).angle>mFirstAngle||(mStones.get(i).angle>=0&&mStones.get(i).angle<180)))
			{
				if(degree>0)//从右向左划
				{
					//>300

					if(mStones.get(i).index==0&&mStones.get(i).angle>mFirstAngle){
						if(m_top_in<mTotalStones.size())
						{
							if(!mStones.get(i).isVisible){
								mStones.get(i).bitmap = mTotalStones.get(m_top_in).bitmap;
								mStones.get(i).index = mTotalStones.get(m_top_in).index;
								mStones.get(i).isVisible = true;
								m_top_in++;
							}
						} else {
							top_in_end = true;
						}

					}

				}else{
					//<180

					if(mStones.get(i).index==0&&mStones.get(i).angle<180){
						if(m_left_in<=0)
						{
							left_in_end = true;
						} else {
							if(!mStones.get(i).isVisible)
							{
								m_left_in--;
								mStones.get(i).bitmap = mTotalStones.get(m_left_in).bitmap;
								mStones.get(i).index = mTotalStones.get(m_left_in).index;
								mStones.get(i).isVisible = true;

							}
						}
					}

				}
			}
			else {
				if(degree>0)//从右向左划
				{

					if(mStones.get(i).index==0){

					} else {

						if(mStones.get(i).index==-1)
						{
							m_left_in = 0;
						} else {
							m_left_in = mStones.get(i).index;
						}
					}


				} else {
					if(mStones.get(i).index==0){

					} else {
						m_top_in = mStones.get(i).index-1;
					}
				}
				mStones.get(i).isVisible = false;
				mStones.get(i).index = 0;
			}

		}

		computeCoordinates();
		invalidate();
	}



	public void autorotateButtons(float velocity) {
//		for( int i = 0; i < mStones.size();i++){
////			LogUtil.v("autorotaButtons:  " + mStones.get(i).index  +"  " + mStones.get(i).mName);
//		}
		new Thread(new FlingRunnable(velocity)).start();
	}

	private boolean m_btnshow = false;
	@Override
	public void onDraw(Canvas canvas) {
		//画一个白色的圆环
		//canvas.drawCircle(mPointX, mPointY, mRadius, mPaint);


		//将每个菜单画出来
		if(mStones!=null)
		{
			for (int index = 0; index < mStones.size(); index++)
			{
				m_btnshow = true;
				if (!mStones.get(index).isVisible)
					continue;
				drawInCenter(canvas, mStones.get(index).bitmap,
						mStones.get(index).x,
						mStones.get(index).y);

			}
		}

		if(m_btnshow)
		{
			Resources res = getResources();
			drawInCenter2(canvas, BitmapFactory.decodeResource(res, R.drawable.depth_customization_confirm), mbtnBack_x,
					mbtnBack_y);
		}
	}

	/**
	 * 获取裁剪后的圆形图片
	 *
	 * @param radius
	 *            半径
	 */
	public Bitmap getCroppedRoundBitmap(Bitmap bmp, int radius) {
		Bitmap scaledSrcBmp;
		int diameter = radius * 2;

		// 为了防止宽高不相等，造成圆形图片变形，因此截取长方形中处于中间位置最大的正方形图片
		int bmpWidth = bmp.getWidth();
		int bmpHeight = bmp.getHeight();
		int squareWidth = 0, squareHeight = 0;
		int x = 0, y = 0;
		Bitmap squareBitmap;
		if (bmpHeight > bmpWidth) {// 高大于宽
			squareWidth = squareHeight = bmpWidth;
			x = 0;
			y = (bmpHeight - bmpWidth) / 2;
			// 截取正方形图片
			squareBitmap = Bitmap.createBitmap(bmp, x, y, squareWidth,
					squareHeight);
		} else if (bmpHeight < bmpWidth) {// 宽大于高
			squareWidth = squareHeight = bmpHeight;
			x = (bmpWidth - bmpHeight) / 2;
			y = 0;
			squareBitmap = Bitmap.createBitmap(bmp, x, y, squareWidth,
					squareHeight);
		} else {
			squareBitmap = bmp;
		}

		if (squareBitmap.getWidth() != diameter
				|| squareBitmap.getHeight() != diameter) {
			scaledSrcBmp = Bitmap.createScaledBitmap(squareBitmap, diameter,
					diameter, true);

		} else {
			scaledSrcBmp = squareBitmap;
		}
		Bitmap output = Bitmap.createBitmap(scaledSrcBmp.getWidth(),
				scaledSrcBmp.getHeight(), Config.ARGB_8888);
		Canvas canvas = new Canvas(output);

		Paint paint = new Paint();
		Rect rect = new Rect(0, 0, scaledSrcBmp.getWidth(),
				scaledSrcBmp.getHeight());

		paint.setAntiAlias(true);
		paint.setFilterBitmap(true);
		paint.setDither(true);
		canvas.drawARGB(0, 0, 0, 0);
		canvas.drawCircle(scaledSrcBmp.getWidth() / 2,
				scaledSrcBmp.getHeight() / 2, scaledSrcBmp.getWidth() / 2,
				paint);
		paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
		canvas.drawBitmap(scaledSrcBmp, rect, rect, paint);
		bmp = null;
		squareBitmap = null;
		scaledSrcBmp = null;
		return output;
	}

	/**
	 * 边缘画圆
	 */
	private void drawCircleBorder(Canvas canvas, float center_x, float center_y, int radius, int color) {
		Paint paint = new Paint();
		/* 去锯齿 */
		paint.setAntiAlias(true);
		paint.setFilterBitmap(true);
		paint.setDither(true);
		paint.setColor(color);
		/* 设置paint的　style　为STROKE：空心 */
		paint.setStyle(Paint.Style.STROKE);
		/* 设置paint的外框宽度 */
		paint.setStrokeWidth(5);
		canvas.drawCircle(center_x, center_y, radius, paint);
	}

	/**
	 * 把中心点放到中心处
	 *
	 * @param canvas
	 * @param bitmap
	 * @param left
	 * @param top
	 */
	private void drawInCenter(Canvas canvas, Bitmap bitmap, float left,
							  float top) {
		Rect dst = new Rect();
		dst.left = (int) (left - menuRadius);
		dst.right = (int) (left + menuRadius);
		dst.top = (int) (top - menuRadius);
		dst.bottom = (int) (top + menuRadius);
		canvas.setDrawFilter(pfd);


		canvas.drawBitmap(bitmap, null, dst, mPaint);

		if(m_cur_sel!=-2)
		{
			for(int i=0; i<mStones.size(); i++) {
				if((mStones.get(i).index==m_cur_sel)&&
						(mStones.get(i).x==left)&&
						(mStones.get(i).y==top))
				{
					//canvas.drawCircle(left, top, menuRadius, mPaint_sel);
					break;
				} else {
					//canvas.drawCircle(left, top, menuRadius, mPaint);
				}
			}
		} else
		{
			//canvas.drawCircle(left, top, menuRadius, mPaint);
		}
	}

	//用来绘制固定位置的返回按钮
	private void drawInCenter2(Canvas canvas, Bitmap bitmap, float left,
							   float top) {
		Rect dst = new Rect();
		dst.left = (int) (left - menuRadius);
		dst.right = (int) (left + menuRadius);
		dst.top = (int) (top - menuRadius);
		dst.bottom = (int) (top + menuRadius);
		canvas.setDrawFilter(pfd);

//		canvas.drawBitmap(getCroppedRoundBitmap(bitmap, menuRadius), null, dst, mPaint);
		canvas.drawBitmap(bitmap, null, dst, mPaint);
//		canvas.drawCircle(left, top, menuRadius, mPaint);

	}

	private int getInCircle(int x, int y) {
		if( mStones == null){
			return -1;
		}
		for (int i = 0; i < mStones.size(); i++) {
			BigStone stone = mStones.get(i);
			int mx = (int) stone.x;
			int my = (int) stone.y;
			if (((x - mx) * (x - mx) + (y - my) * (y - my)) < menuRadius
					* menuRadius) {
				return i;
			}
		}
		return -1;
	}

	private int getInOk(int x, int y)
	{
		int mx = (int) mbtnBack_x;
		int my = (int) mbtnBack_y;
		if (((x - mx) * (x - mx) + (y - my) * (y - my)) < menuRadius
				* menuRadius) {
			return 1;
		} else {
			return -1;
		}
	}

	public void setOnRoundSpinViewListener(onRoundSpinViewListener listener){
		this.mListener = listener;
	}

	public void setCenterCoordinate( int x, int y){

		mPointX = x ;
		mPointY = y ;

		mbtnBack_x = mPointX
				+ (float) (mRadius * Math.cos(Math.toRadians(mFirstAngle - 30)));
		mbtnBack_y = mPointY
				+ (float) (mRadius * Math.sin(Math.toRadians(mFirstAngle - 30)));
	}

	//radio代表menu的半径是一半屏幕的x分之一
	public void setMenuRadius( int radio){
		menuRadio = radio;
	}

	//设置menu的初始化角度
	public void setFirstAngle( int firstAngle ){
		mFirstAngle = firstAngle;
	}

}
